import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:i18n_demo/Localizations/localizations.dart';
import 'package:i18n_demo/Localizations/localizations_delegate.dart';
import 'package:i18n_demo/generated/l10n.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // 启动要显示的界面
      home: HomePage(),
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate, // 指定本地化的字符串和一些其他的值
        GlobalCupertinoLocalizations.delegate, // 对应的Cupertino风格
        GlobalWidgetsLocalizations.delegate, // 指定默认的文本排列方向, 由左到右或由右到左
        JKLocalizationsDelegate.delegate,
        S.delegate
      ],
      /*
      supportedLocales: [
        Locale('en'),
        Locale('zh')
      ],
       */
      supportedLocales: S.delegate.supportedLocales,
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(S.of(context).title),
      ),
      body:Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(S.of(context).greet),
            RaisedButton(
              child: Text(S.of(context).picktime, style: TextStyle(fontSize: 20, color:  Colors.orange),),
                onPressed: () {
                  showDatePicker(
                    context: context,
                    initialDate: DateTime.now(),
                    firstDate: DateTime(2000),
                    lastDate: DateTime(3000)
                  );
                }
            )
          ],
        ),
      ),
    );
  }
}
/*
Text(JKLocalizations.of(context).greet),

*/
